<template>
  <div class="select-company-dialog-container">
    <el-dialog
      v-model="dialogVisible"
      :before-close="handleClose"
      :title="translate(title)"
      width="40%"
    >
      <el-form label-position="left" label-width="60px">
        <el-form-item :label="translate('内容') + '：'">
          <!-- <div class="content">{{ data.Json }}</div> -->
          <div class="content">
            <!-- <pre>{{ JSON.stringify(JSON.parse(data.Json), null, 2) }}</pre> -->
            <pre>{{ data.Json }}</pre>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="handleClose">{{ translate('取消') }}</el-button>
        <el-button type="primary" @click="confirm">
          {{ translate('确定') }}
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import { translate } from '@/i18n'
  const props = defineProps({
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '详情',
    },
    data: {
      type: Object,
      default: () => {},
    },
  })
  const dialogVisible = ref(false)
  watch(
    () => props.visible,
    () => {
      dialogVisible.value = props.visible
    }
  )
  const emit = defineEmits(['close', 'confirm'])
  const handleClose = () => {
    dialogVisible.value = false
    emit('close', dialogVisible.value)
  }
  const confirm = () => {
    emit('confirm')
    // dialogVisible.value = false
  }
</script>

<style lang="scss" scoped>
  .select-company-dialog-container {
    .content {
      width: 100%;
      word-break: break-all;

      pre {
        white-space: pre-wrap;
        white-space: -moz-pre-wrap;
        white-space: -pre-wrap;
        white-space: -o-pre-wrap;
        word-wrap: break-word;
        margin: 0;
      }
    }
  }
</style>
